import React,{Component} from "react"
import "./index.scss"
import usermobx from "*/mobx/user"
import datamobx from "*/mobx/data"
import {observer} from "mobx-react"
import {Carousel} from "antd"
const rollList=[
    "普通用户","管理员","超级管理员"
]
@observer
 class Home extends Component{
     componentDidMount(){
         if(!datamobx.homedata){
             datamobx.getHomedata("/api/homebanner")
         }
     }
    render(){
        return(
            <div>
               {
                   usermobx.userinfo&&<h2>
                       首页/欢迎 ~{rollList[usermobx.userinfo.rolltype-1]}
                   </h2>
               }
               <Carousel
               autoplay
               dots
               className="home-banner"
               >
                   {
                       datamobx.homedata&&datamobx.homedata.map((item,i)=>{
                           return(
                               <div key={i}>
                                   <img src={item.imgUrl}></img>
                                   <a >{item.text}</a>
                               </div>
                           )
                       })
                   }
               </Carousel>
            </div>
        )
    }
}
export default Home